package com.mz.ozy.widget.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.mz.ozy.R;
import com.mz.ozy.utils.ToastUtils;


public class AddRoleWindow extends BasePopupWindow implements View.OnClickListener {
    private OnClickListener mOnClickListener;
    private Context mContext;

    private EditText mEtAccount;
    private EditText mEtInviteCode;

    public AddRoleWindow(Context mContext, OnClickListener mOnClickListener) {
        super(mContext, R.layout.pop_window_add_role, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
        this.mOnClickListener = mOnClickListener;
        this.mContext = mContext;
        init();
    }

    private void init() {
        getView(R.id.item_root_view).setOnClickListener(this);
        getView(R.id.bottomView).setOnClickListener(this);
        getView(R.id.deleteIv).setOnClickListener(this);
        getView(R.id.confirmBt).setOnClickListener(this);
        mEtAccount = getView(R.id.et_account);
        mEtInviteCode = getView(R.id.et_invite_code);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.item_root_view:
            case R.id.deleteIv:
                dismiss();
                break;
            case R.id.bottomView:
                break;
            case R.id.confirmBt:
                //登录密码
                String nickName = mEtAccount.getText().toString().trim();
                if (TextUtils.isEmpty(nickName)) {
                    ToastUtils.showToast(mContext.getString(R.string.str_sk_nickname_hint));
                    return;
                }
                String inviteCode = mEtInviteCode.getText().toString().trim();
                mOnClickListener.onConfirm(nickName, inviteCode);
                dismiss();
                break;
        }

    }

    public interface OnClickListener {
        void onConfirm(String nickName, String inviteCode);
    }
}
